package com.example.springbootparamvalidatedemo.controller;

import com.example.springbootparamvalidatedemo.constant.BaseConstant;
import com.example.springbootparamvalidatedemo.dto.StudentDto;
import com.example.springbootparamvalidatedemo.dto.TeacherDto;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chaird
 * @create 2021-06-18 22:03
 */
@RestController
public class HelloController {

  @PostMapping("/studentHello")
  public StudentDto studentHello(@Validated @RequestBody StudentDto student) {
    return student;
  }

  @PostMapping("/insertTeacherHello")
  public TeacherDto insertTeacherHello(
      @Validated(BaseConstant.Insert.class) @RequestBody TeacherDto teacherDto) {
    return teacherDto;
  }

  @PostMapping("/updateTeacherHello")
  public TeacherDto updateTeacherHello(
      @Validated(BaseConstant.Update.class) @RequestBody TeacherDto teacherDto) {
    return teacherDto;
  }

  @PostMapping("/teacherHello")
  public TeacherDto teacherHello(@Validated @RequestBody TeacherDto teacherDto) {
    return teacherDto;
  }
}
